//
//  ViewController.swift
//  SegmentedView
//
//  Created by lizhi on 2021/12/10.
//

import UIKit

class ViewController: UIViewController {

    var segmentedView = QCSegmentedView()
    var containerView = QCSegmentedListContainerView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        setupSegmentedVieew()
        
        
        
        setupContaierListView()
        
    }
    
    func setupSegmentedVieew() {
        segmentedView.frame = CGRect(x: 20, y: 100, width: 300, height: 60)
        segmentedView.backgroundColor = UIColor.red
        self.view.addSubview(segmentedView)
        
        segmentedView.listContainer = self.containerView
    }
    
    func setupContaierListView()  {
        self.containerView.dataSource = self
        containerView.frame = CGRect(x: 20, y: 200, width: 300, height: 200)
        self.view.addSubview(containerView)
        containerView.backgroundColor = UIColor.green
    }
    
//    public init(dataSource: QCSegmentedListContainerViewDataSource) {
////        self.dataSource = dataSource
////        super.init(frame: CGRect.zero)
//        super.init(nibName: nil, bundle: nil)
//
//    }
    
//    required init?(coder: NSCoder) {
//        fatalError("init(coder:) has not been implemented")
//    }
    
    

}

extension ViewController:QCSegmentedListContainerViewDataSource {
    func listContainerView(_ listContainerView: QCSegmentedListContainerView, initListAt index: Int) -> QCSegmentedListContainerViewListDelegate {
        return NewsController()
    }
    
    func numberOfLists(in listContainerView: QCSegmentedListContainerView) -> Int {
        return 5
    }
    
    func searchClick(inputText: String) {
        
    }
    
    
}

